<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />

		<script src="./hls.min.js"></script>
		<script src="./DPlayer.min.js"></script>
		<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js">
		</script>


	</head>

	<body style="margin: 0px;height: 230px;">
		<div id="dplayer" style="position: absolute;top: 0px;height: 230px;"></div>
		<script>
			let playUrl = getQuery('url');
			console.log(playUrl)
			let pic = ''
			const dp = new DPlayer({
				container: document.getElementById('dplayer'),
				video: {
					url: playUrl,
					type: 'hls',
					pic: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F01597358de2bf1a801219c774feab7.gif&refer=http%3A%2F%2Fimg.zcool.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1649072663&t=4abf867038bb2b034d74c53cb775f7c8',
				},
				autoplay: true,
				playbackSpeed: [0.75, 1, 1.5, 2, 2.5, 3],
				danmaku: true,
				pluginOptions: {
					hls: {
						// hls config
					},
				},
			});
			//取url中的参数值
			function getQuery(name) {
				// 正则：[找寻'&' + 'url参数名字' = '值' + '&']（'&'可以不存在）
				let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
				let r = window.location.search.substr(1).match(reg);
				console.log(r);
				if (r != null) {
					// 对参数值进行解码
					return decodeURIComponent(r[2]);
				}
				return null;
			}
			window.myHistory = () => {
				uni.postMessage({
					data: {
						initialTime: dp.video.currentTime,
						gDuration: dp.video.duration
						
					}
				})
			}
		</script>
	</body>

</html>
